#!/usr/bin/env python
# coding=utf-8
from flask import Blueprint

from plant.base.beanret import BeanRet
from plant.service.barometersv import PiBMP280

pitop = Blueprint('barometer', __name__)


@pitop.route('/barometer/read')
def read():
    '''
    read tem and humi
    :return:
    '''
    pi_bmp280 = PiBMP280()
    temperature, pressure = pi_bmp280.readBMP280All()
    return BeanRet(success=True, data={'temp': temperature, 'pressure': pressure}).toJson()
